<?
	require_once('init.php');
	require_once('dataModel.php');
	if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
	{
		$h_tourl="login.php";
		header("Location:".$h_tourl);
		exit;
	}
	if($_POST){
		$IMAGEFile = $_FILES;
		if(!empty($IMAGEFile['file']['name'])){
			if($filename = uplodfile($IMAGEFile)){
				$name = $_POST['name'];
				$name_e = $_POST['name_e'];
				$displayorder = $_POST['displayorder'];
				if(empty($displayorder)){
					$displayorder = 0;
				}
				$dateline = time();
				$qry ="INSERT INTO images (`name`,`name_e`,`url`,`displayorder`,`dateline`) ";  
				$qry.= "VALUES ('$name','$name_e','$filename','$displayorder','$dateline') "; 		
				$db = MySQL::getInstance('','r-w'); 
				if($DBR=$db->update($qry)){
					echo "<script>alert('添加成功');window.location.href='imagemanager.php';</script>";
				}else{
					echo "<script>alert('添加失败');window.location.href='imagemanager.php';</script>";
				}
				
			}else{
				echo "<script>alert('图片上传失败');window.location.href='imagemanager.php';</script>";
			}
		}else{
			echo "<script>alert('请上传图片');window.location.href='imagemanager.php';</script>";
		}
	}
	
	$Title = "添加首页图片";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=<?=$lng_characset;?>" />
	<title><?=$AllPageTitle;?></title>
	<link href="css/CenterMenu.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="css/Buttonstyle.css" type="text/css" media="screen" />	
	
	<? include("alljs.php"); ?>
	<!--script src="Scripts/jquery.min.js" type="text/javascript"></script>
	<script src="Scripts/jquery.ui.draggable.js" type="text/javascript"></script>
	<script src="Scripts/jquery.hiAlerts-min.js" type="text/javascript"></script-->
	
	<script language="javascript">
		function goback(pgno)
		{
			self.location='colormanager.php?pgno='+pgno
		}

		
	</script>
</head>


<body>
	<div id="MenuRighttitle" ><div style="padding-left:245px;padding-top:5px;"><b><?=$Title;?></b></div></div>

	<div class="inner-container">
		<div class="bodypart" style="border:0px solid blue;">	
			<div style="padding-left: 10px; margin-top: 20px; text-align: left; height:auto;border:0px solid blue;">
				<form id="add_form" method="post" name="add_form" enctype="multipart/form-data">
					<div class="coloraddnew_a01"><?=$lang['strImageName'].":";?></div>
					<div class="coloraddnew_a02" ><input type="text" id="name" name="name" value="" size="30" maxlength="20" class="goodsaddnew_textbox" style="width:280px;" /></div>
	
					<div class="coloraddnew_a01"><?=$lang['strImageName']."(".$strEnglish."):";?></div>
					<div class="coloraddnew_a02" ><input type="text" id="name_e" name="name_e" value="" size="30" maxlength="20" class="goodsaddnew_textbox" style="width:280px;" /></div>
	
					<div class="coloraddnew_a01"><?=$lang['strDisplayOrder'].":";?></div>
					<div class="coloraddnew_a02" ><input type="text" id="displayorder" name="displayorder" value="" size="30" maxlength="20" class="goodsaddnew_textbox" style="width:280px;" /></div>
	
					<div class="coloraddnew_a01"><?=$lang['strUploadImage'].":";?></div>
					<div class="coloraddnew_a02" >
					<input type="file" name="file" size="30" maxlength="20" class="goodsaddnew_textbox" style="width:280px;" />
					</div>
					<div class="coloraddnew_a01" style="margin-top: 50px;width:700px;text-align:center;border:0px solid blue;">
						<input type="image" name="image" value="image" src="images/submit_btn.gif" /> 
						<input type="image" name="image" value="image" src="images/go_btn.gif"  onclick="javascript:goback('<?=$pgno;?>');" /> 
					</div>
				</form>
			</div>
		</div>
	</div>
</body>

</html>
